unit DataBaseConfig;

interface
uses
  Classes,SysUtils,ADODB,DB;

type
  TDataBaseConfig = class(TPersistent)
  private
    FPassWord:string;
    FUserCode:string;
    FDataBase:string;
    FDbServer:string;
  published
    property PassWord:string  read FPassWord write FPassWord;
    property UserCode:string  read FUserCode write FUserCode;
    property DataBase:string  read FDataBase write FDataBase;
    property DbServer:string  read FDbServer write FDbServer;
  public

  end;

var
  DbConfig:TDataBaseConfig;

implementation
uses
  NativeXmlObjectStorage;

initialization
begin
  if DbConfig = nil then
  begin
    DbConfig := TDataBaseConfig.Create;
    DbConfig.PassWord := '123456';
    DbConfig.UserCode := 'sa';
    DbConfig.DataBase := 'test';
    DbConfig.DbServer := '127.0.0.1';

    if not FileExists(ExtractFilePath(ParamStr(0))+'config.xml') then
    begin
      NativeXmlObjectStorage.ObjectSaveToXmlFile(DbConfig,ExtractFilePath(ParamStr(0))+'config.xml');
    end;
  end;

  if FileExists(ExtractFilePath(ParamStr(0))+'config.xml') then
  begin
    NativeXmlObjectStorage.ObjectLoadFromXmlFile(DbConfig,ExtractFilePath(ParamStr(0))+'config.xml');
  end;
end;

finalization
begin
  if DbConfig <> nil then FreeAndNil(DbConfig);
end;

end.
